package controller;

import java.io.File;
import javax.swing.filechooser.FileFilter;

public class SVGFilter extends FileFilter {

    // Accept all directories and all svg files.
    public boolean accept(File f) {
	if (f.isDirectory()) {
	    return true;
	}

	String extension = null;

	// If its a file get its extension
	if (f.isFile()) {

	    String[] filesplit = f.getName().split("\\.");

	    // Grab the extension
	    if (filesplit.length > 1)
		extension = filesplit[filesplit.length - 1];

	}

	if (extension != null) {

	    if (extension.equals("svg"))
		return true;
	    else
		return false;

	}

	return false;
    }

    // The description of this filter
    public String getDescription() {
	return "SVG Files";
    }

}
